//
//  YCJoinHEOFooterView.m
//  HeartWorldClient
//
//  Created by 董知樾 on 2016/11/16.
//  Copyright © 2016年 谭明权. All rights reserved.
//

#import "YCJoinHEOFooterView.h"

@interface YCJoinHEOFooterView ()
@property (copy, nonatomic) void(^didClickBlock)();
@end

@implementation YCJoinHEOFooterView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    self.backgroundColor = [UIColor whiteColor];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.titleLabel.font = [UIFont systemFontOfSize:16];
    [self addSubview:btn];
    [btn setTitle:@"+ 添加被援助人" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor colorWithRGBValue:0xef4a65] forState:UIControlStateNormal];
    btn.layer.cornerRadius = 3;
    btn.layer.borderWidth = 1;
    btn.layer.borderColor = [UIColor colorWithRGBValue:0xef4a65].CGColor;
    btn.layer.masksToBounds = YES;
    [btn addTarget:self action:@selector(Action) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 10, 0, 10));
    }];
}
-(void)Action{
    if (_didClickBlock) {
        _didClickBlock();
    }
    
}
-(void)didClickWith:(void (^)())block{
    _didClickBlock = block;
    
}
@end



@interface YCJoinHEOSectionHeaderView ()

@property (strong, nonatomic) UILabel *titleLabel;

@property (strong, nonatomic) UIButton *lookMoreBtn;

@property (copy, nonatomic) void(^didClickLookMoreBlock)(void);

@property (copy, nonatomic) void(^didClickBlock)();

@end


@implementation YCJoinHEOSectionHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    _titleLabel = [[UILabel alloc]init];
    _titleLabel.font = [UIFont systemFontOfSize:14];
    _titleLabel.textColor = [UIColor colorWithRGBValue:0x999999];
    _titleLabel.layer.masksToBounds = YES;
    _titleLabel.backgroundColor = self.contentView.backgroundColor;
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5);
        make.leading.mas_equalTo(12);
    }];
    
    _lookMoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_lookMoreBtn addTarget:self action:@selector(didClickLookMoreBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_lookMoreBtn];
    [_lookMoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5);
        make.height.mas_equalTo(25);
        make.width.mas_equalTo(150);
    }];
    
    UILabel *lookMoreLabel = [[UILabel alloc]init];
    lookMoreLabel.font = [UIFont systemFontOfSize:14];
    lookMoreLabel.textColor = [UIColor colorWithRGBValue:0x999999];
    lookMoreLabel.text = @"查看更多援助";
    [_lookMoreBtn addSubview:lookMoreLabel];
    [lookMoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-25);
        make.centerY.equalTo(_lookMoreBtn);
    }];
    
    UIImageView *arrowImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"message_arrow"]];
    [_lookMoreBtn addSubview:arrowImageView];
    [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(7, 14));
        make.trailing.mas_equalTo(-15);
        make.centerY.equalTo(_lookMoreBtn);
    }];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.titleLabel.font = [UIFont systemFontOfSize:16];
    btn.titleLabel.backgroundColor = btn.backgroundColor;
    btn.titleLabel.layer.masksToBounds = YES;
    [self addSubview:btn];
    [btn setTitle:@"+ 添加被援助人" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor colorWithRGBValue:0xef4a65] forState:UIControlStateNormal];
    btn.layer.cornerRadius = 3;
    btn.layer.borderWidth = 1;
    btn.layer.borderColor = [UIColor colorWithRGBValue:0xef4a65].CGColor;
    btn.layer.masksToBounds = YES;
    [btn addTarget:self action:@selector(Action) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(30, 10, 0, 10));
    }];
    
}
-(void)Action{
    if (_didClickBlock) {
        _didClickBlock();
    }
    
}
-(void)didClickWith:(void (^)())block{
    _didClickBlock = block;
    
}
- (void)didClickLookMoreBtn:(UIButton *)btn {
    if (_didClickLookMoreBlock) {
        _didClickLookMoreBlock();
    }
}

- (void)hideLookMoreBtn:(BOOL)hide {
    _lookMoreBtn.hidden = hide;
}

- (void)setTitle:(NSString *)title {
    _titleLabel.text = title;
}

- (void)didClickLookMoreWith:(void(^)(void))block {
    _didClickLookMoreBlock = block;
}

@end
